home *** CD-ROM | disk | FTP | other *** search
/ Adobe Graphics & Publishing SDK 1996 December / Adobe Graphics & Publishing SDK 1996 December.iso / mac / PageMaker 6.5 SDK Mac / SourceCode / C_Language / Open / Common / OPENCPY.CPP < prev    next >
C/C++ Source or Header  |  1996-08-12  |  3KB  |  119 lines

  1. /*
  2.  *--- opencpy.cpp ----------------------------------------------------------
  3.  * Copyright (c) 1992-96 Adobe Systems, Inc.  All rights reserved.
  4.  *
  5.  * PageMaker plug-in OpenCopy.
  6.  *-----------------------------------------------------------------------
  7.  */
  8.  
  9. /* ---------------- PageMaker SDK include files ---------------- */
  10. #include "PMPlugin.h"
  11.  
  12. /* ---------------- Plug-in include files ---------------- */
  13. #include "OpenCpy.h"
  14. #ifdef MACINTOSH
  15.     #include "WinTypes.h"
  16.     #include "PStrUtils.h"
  17. #endif // MACINTOSH
  18.  
  19. /* ---------------- Cross-platform include files ---------------- */
  20.  
  21. /* ---------------- Platform specific include files ---------------- */
  22. #ifdef MACINTOSH
  23.     #include <types.h>
  24.     #ifndef powerc
  25.         #include <A4Stuff.h>
  26.         #include <SetUpA4.h>
  27.     #endif
  28. #else
  29.     #include <windows.h>
  30. #endif
  31.  
  32. /* ---------------- Type definitions ---------------- */
  33.  
  34. /* ---------------- Definitions ---------------- */
  35. #define        CB_PATH_BUFF        1000
  36. #define        CB_NAME_BUFF        300
  37.  
  38. /* ---------------- PageMaker (New)SDK include files ---------------- */
  39.  
  40. /* ---------------- Globals ---------------- */
  41. extern    sPMParamBlockPtr thePB;
  42.  
  43. /* ---------------- Function declarations ---------------- */
  44. #ifdef WINDOWS
  45. extern BOOL    FGetOpenFileName(char *szPName, short cbPSz, char *szSName, short cbSSz ); 
  46. #endif // WINDOWS
  47.  
  48. void OpenPubCopy(void)
  49. {
  50.     //return;
  51.     BOOL    result;
  52. #ifdef WINDOWS
  53.     char    *szPathName = NULL;
  54.     char    *szShortName = NULL;
  55. #endif //WINDOWS
  56. #ifdef MACINTOSH
  57.     Point        point;
  58.     short         numTypes = 1;
  59.     SFTypeList    typeList;
  60.     SFReply        reply;
  61. #endif // MACINTOSH
  62.     struct OpenPub {
  63.         char    szPathDestination[91];
  64.         short    how;
  65.     } OpenRec;
  66.  
  67. #ifdef WINDOWS
  68.      szPathName = (char *)GlobalAlloc( GPTR, CB_PATH_BUFF );
  69.     szShortName = (char *)GlobalAlloc( GPTR, CB_NAME_BUFF );
  70.  
  71.      if ( !szPathName || !szShortName )
  72.         goto cleanup;
  73.  
  74.     result = FGetOpenFileName(szPathName, CB_PATH_BUFF, szShortName, CB_NAME_BUFF);
  75.  
  76.     memset(OpenRec.szPathDestination, 0, 91);
  77.  
  78.     strncpy( OpenRec.szPathDestination, szPathName, 91 );
  79. #endif // WINDOWS
  80.  
  81. #ifdef MACINTOSH
  82.     point.h = 100;
  83.     point.v = 100;
  84.     typeList[0] = 'AB65';
  85.  
  86.     SFGetFile(point, "\pLocate PageMaker file:", nil, numTypes, typeList,
  87.                 nil, &reply);
  88.  
  89.     if (reply.good == false)
  90.         return;
  91.         
  92.     memset(OpenRec.szPathDestination, 0, 91);
  93.  
  94.     p_to_c( OpenRec.szPathDestination, reply.fName);
  95.  
  96. #endif //MACINTOSH
  97. /*
  98.     struct OpenPub {
  99.         char    szPathDestination[91];
  100.         short    how;
  101.     } OpenRec;
  102. */
  103.     OpenRec.how = 1;
  104.  
  105.     result = PBBinCommand(thePB, pm_open, kXRSPointer, &OpenRec, sizeof(struct OpenPub));
  106.  
  107. cleanup:
  108. #ifdef WINDOWS
  109.     if ( szPathName )
  110.         GlobalFree( szPathName );
  111.     if ( szShortName )
  112.         GlobalFree( szShortName );
  113. #endif //WINDOWS
  114. #ifdef MACINTOSH
  115.  
  116. #endif // MACINTOSH
  117.     return;
  118. }
  119.